package com.push.quartz.task;

import com.push.spider.spider.*;
import com.push.web.service.IBizSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("myTask")
public class MyTask {

    public void CommSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        CommSpider spider = new CommSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始CommSpider】");
        startTime = System.currentTimeMillis();
        spider.createCrawler().run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束CommSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void ClientSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        HttpClientSpider spider = new HttpClientSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始ClientSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束ClientSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }


    public void rss(String sourceId)
    {
        System.out.println("执行RSS任务：" + sourceId);
        RSSSpider spider = new RSSSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始rss】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束rss】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void USDefenseSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        USDefenseSpider spider = new USDefenseSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始USDefenseSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束USDefenseSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }


    public void NasaNewsSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        NasaNewsSpider spider = new NasaNewsSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始NasaNewsSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束NasaNewsSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void USweatherSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        USweatherSpider spider = new USweatherSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始USweatherSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束USweatherSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void DailySpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        DailySpider spider = new DailySpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始DailySpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束DailySpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void HuanqiuSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        HuanqiuSpider spider = new HuanqiuSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始HuanqiuSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束HuanqiuSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void NasaReleasesSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        NasaReleasesSpider spider = new NasaReleasesSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始NasaReleasesSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束NasaReleasesSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void EuCommissionSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        EuCommissionSpider spider = new EuCommissionSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始EuCommissionSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束EuCommissionSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void ArenaSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        ArenaSpider spider = new ArenaSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始ArenaSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束ArenaSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void InvestorsSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        InvestorsSpider spider = new InvestorsSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始InvestorsSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束InvestorsSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void TwHttpClientSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        TwHttpClientSpider spider = new TwHttpClientSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始TwHttpClientSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束TwHttpClientSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void CwbGovTwSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        CwbGovTwSpider spider = new CwbGovTwSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始CwbGovTwSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束CwbGovTwSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void NetKoreaSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        NetKoreaSpider spider = new NetKoreaSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始NetKoreaSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束NetKoreaSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void WebDriverSpider(String sourceId)
    {
        System.out.println("执行爬虫任务：" + sourceId);
        WebDriverSpider spider = new WebDriverSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始WebDriverSpider】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束WebDriverSpider】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }

    public void dailyRss(String sourceId)
    {
        System.out.println("执行RSS任务：" + sourceId);
        DailyRssSpider spider = new DailyRssSpider(sourceId);
        long startTime, endTime;
        System.out.println("【爬虫开始dailyRss】");
        startTime = System.currentTimeMillis();
        spider.run();
        endTime = System.currentTimeMillis();
        System.out.println("【爬虫结束dailyRss】共抓取篇"+spider.getSize()+"文章，耗时约" + ((endTime - startTime) / 1000) + "秒");
    }



}
